using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace Pay.Data {
    public partial class ProductMap
        : System.Data.Entity.ModelConfiguration.EntityTypeConfiguration<Product> {
        public ProductMap() {
            // table
            ToTable("mc_Product", "dbo");

            // keys
            HasKey(t => t.Id);

            // Properties
            Property(t => t.Id)
                .HasColumnName("Id")
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .IsRequired();
            Property(t => t.MerchantId)
                .HasColumnName("MerchantId")
                .IsRequired();
            Property(t => t.Name)
                .HasColumnName("Name")
                .HasMaxLength(200)
                .IsRequired();
            Property(t => t.Code)
                .HasColumnName("Code")
                .HasMaxLength(100)
                .IsOptional();
            Property(t => t.Props)
                .HasColumnName("Props")
                .HasMaxLength(4000)
                .IsOptional();
            Property(t => t.ShortDescription)
                .HasColumnName("ShortDescription")
                .HasMaxLength(2000)
                .IsOptional();
            Property(t => t.CategoryId)
                .HasColumnName("CategoryId")
                .IsOptional();
            Property(t => t.MarketPrice)
                .HasColumnName("MarketPrice")
                .HasPrecision(18, 2)
                .IsRequired();
            Property(t => t.Price)
                .HasColumnName("Price")
                .HasPrecision(18, 2)
                .IsRequired();
            Property(t => t.Integral)
                .HasColumnName("Integral")
                .IsRequired();
            Property(t => t.Freight)
                .HasColumnName("Freight")
                .HasPrecision(18, 2)
                .IsOptional();
            Property(t => t.ImagePath)
                .HasColumnName("ImagePath")
                .HasMaxLength(2000)
                .IsRequired();
            Property(t => t.SaleCount)
                .HasColumnName("SaleCount")
                .IsRequired();
            Property(t => t.Top)
                .HasColumnName("Top")
                .IsRequired();
            Property(t => t.Description)
                .HasColumnName("Description")
                .IsOptional();
            Property(t => t.CreateTime)
                .HasColumnName("CreateTime")
                .IsRequired();
            Property(t => t.UpdateTime)
                .HasColumnName("UpdateTime")
                .IsRequired();
            Property(t => t.SaleStatus)
                .HasColumnName("SaleStatus")
                .IsRequired();
            Property(t => t.AuditStatus)
                .HasColumnName("AuditStatus")
                .IsRequired();
            Property(t => t.AuditReason)
                .HasColumnName("AuditReason")
                .HasMaxLength(1000)
                .IsOptional();
            Property(t => t.Type)
                .HasColumnName("Type")
                .IsRequired();
			Property(t=>t.Tag)
				.HasColumnName("Tag")
				.IsOptional();
			Property(t=>t.IsSeas)
				.HasColumnName("IsSeas")
				.IsRequired();
			Property(t=>t.Country)
				.HasColumnName("Country")
				.IsOptional();
            Property(t => t.Weight)
                .HasColumnName("Weight")
                .IsOptional();
            Property(t => t.WeightUnit)
                .HasColumnName("WeightUnit")
                .IsOptional();
            Property(t => t.Tax)
                .HasColumnName("Tax")
                .IsOptional();
            Property(t => t.GoodDecId)
                .HasColumnName("GoodDecId")
                .IsOptional();
            Property(t => t.Depth)
              .HasColumnName("Depth")
              .IsOptional();
            Property(t => t.Path)
              .HasColumnName("Path")
              .HasMaxLength(4000)
              .IsOptional();
            Property(t => t.CostPrice)
                .HasColumnName("CostPrice")
                .IsOptional();
            Property(t => t.DistributionPrice)
             .HasColumnName("DistributionPrice")
             .IsOptional();

            // Relationships
            HasRequired(t => t.Merchant)
                .WithMany()
                .HasForeignKey(d => d.MerchantId)
                .WillCascadeOnDelete(false);
            HasOptional(t => t.Category)
                .WithMany()
                .HasForeignKey(d => d.CategoryId)
                .WillCascadeOnDelete(false);
            HasOptional(t => t.GoodDeclaration)
               .WithMany()
               .HasForeignKey(d => d.GoodDecId)
               .WillCascadeOnDelete(false);
        }
    }
}
